package com.mit.config;

import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Properties;

import org.apache.log4j.Logger;

public class AppConfiguration {

	private static Logger logger = Logger.getLogger(AppConfiguration.class);
	
	private static final String FILE_LOCATION = "resources/beans.properties";
	private static String[] springConfigFiles = null;
	
	static{
		InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(FILE_LOCATION);
		Properties p = new Properties();
		try {
			p.load(is);			
		} catch (IOException e) {
			logger.error("Unable to read file: " + FILE_LOCATION, e);
		}
		springConfigFiles = new String[p.size()];
		Enumeration en = p.keys();		
		for(int i = 0; i < p.size(); i++){
			springConfigFiles[i] = p.getProperty(en.nextElement().toString());
			logger.debug("Load file: " + springConfigFiles[i]);

		}
		
	}
	
	public static String[] getSpringConfigFiles(){
		return springConfigFiles;
	}
}
